import {
	isEmpty
} from '@/utils/index';
import uCharts from '@/components/u-charts/u-charts';


/*
用户模块的混合
 */
var report = {
	data() {
		return {
			colors:['#1890ff', '#2fc25b', '#facc14', '#f04864', '#8543e0', '#90ed7d',
			        '#d8aa06','#13227a','#8a8a8a','#ff96aa','#12dddb','#1a8829']
		}
	},
	methods: {
		handleRadarData(canvasObj, originData, targetData, canvasId) {
			if (isEmpty(originData)) {
				return;
			}
			originData.forEach((item,index)=>{
				item.name = item.pointName;
				item.data = item.value_num;
				const colorIndex = index%this.colors.length;
				item.color = this.colors[colorIndex];
				targetData.series.push(item);
			});
			if(targetData.series.length>5){
				targetData.height = uni.upx2px(700);
			}else{
				targetData.height = uni.upx2px(500);
			}
			this.showPie(canvasObj, canvasId, targetData);
		},

		showPie(canvasObj, canvasId, chartData) {
			let _self = this;
			canvasObj = new uCharts({
				$this: _self,
				canvasId: canvasId,
				type: 'pie',
				fontSize: 10,
				legend: true,
				background: '#FFFFFF',
				pixelRatio: _self.pixelRatio,
				series: chartData.series,
				animation: true,
				width: chartData.width * _self.pixelRatio,
				height: chartData.height * _self.pixelRatio,
				dataLabel: true,
				extra: {
					pie: {
						lableWidth: 15
					}
				},
			});
		},


		// 		showRadar(canvasObj, canvasId, radarData) {
		// 			let _self = this;
		// 			canvasObj = new uCharts({
		// 				$this: _self,
		// 				canvasId: canvasId,
		// 				type: 'radar',
		// 				fontSize: 9,
		// 				legend: false,
		// 				background: '#FFFFFF',
		// 				pixelRatio: _self.pixelRatio,
		// 				animation: false,
		// 				dataLabel: false,
		// 				categories: radarData.categories,
		// 				series: radarData.series,
		// 				width: radarData.width * _self.pixelRatio,
		// 				height: radarData.height * _self.pixelRatio,
		// 				extra: {
		// 					radar: {
		// 						max: 100,
		// 					}
		// 				}
		// 			});
		// 		},
		// 

		// touchRadarOne(e) {
		// 	console.log('touchRadarOne');
		// 	canvasRadar.showToolTip(e, {
		// 		format: function(item, category) {
		// 			return item.name + ':' + item.data
		// 		}
		// 	});
		// },

		// touchRadarTwo(e) {
		// 	this.radarTwo.canvasRadar.showToolTip(e, {
		// 		format: function(item, category) {
		// 			return item.name + ':' + item.data
		// 		}
		// 	});
		// }
	}
}
export default report
